﻿@model trangbaocao.Models.GeneratorModel
<div class="container_12">       
    <div class="grid_12">            
        <div class="module">
                <h2 align="right"><span align="right"><a href="@Url.Action("Index", "Generator")">Quay lại</a></span></h2>                        
                <div class="module-body">
                @using (Html.BeginForm("EditGenerator", "Generator", FormMethod.Post, new { id = "EditGenerator" }))
                {                      
                    <div align="center" style="margin-bottom:10px;">
                        <h3>SỬA THÔNG TIN THIẾT BỊ TRONG TRẠM</h3>
                        <div class="account" align="center"> <img src="../../Content/Body/Images/Body_Images/Edit_Device.png" width="12%" /></div>
                    </div>
                    if (TempData["msg"] != null)
                    {                            
                        <span class="notification n-error">@TempData["msg"]</span>
                    }        
                    
                    <p align="center">
                        <label style="width:26%; text-align:left;">Trung tâm:</label>
                        @if (Model.trungtam_id != null)
                        { 
                            @Html.DropDownListFor(x => x.main_stations_id, Model.trungtam_id)                     
                        }
                    </p>
                    <p align="center" style="padding-left:11px; width:100%">
                        <label style="width:28.6%; text-align:left;">Trạm:</label>
                             @if (Model.tram_id != null)
                                {                                  
                                    @Html.DropDownListFor(x => x.stations_id, Model.tram_id)
                                }    
                                     <font color="red">(*)</font>
                             
                        <label style="width:26%; text-align:left;">
                            @Html.ValidationMessageFor(model => model.stations_id)
                        </label>                    
                    </p>
                    
                    <div align="center">
                        <label style="width:26%; text-align:left;">Ngày </label>
                            <p align="center" style="width:27%; text-align:left;">
                                @Html.TextBoxFor(model => model.ngay, new { @name = "ngay", @class = "date" })
                            </p>                        
                    </div>
                    
                    <p align="center">
                        <label style="width:26%; text-align:left;">Trang thai:</label>
                        @Html.TextBoxFor(model => model.status, new { @name = "status", @class = "input-short" })                        
                    </p>                 
                                     
                    <div class="button" align="center">
                        <p align="center" style="width:26%; text-align:left;">
                            <input class="submit-green" type="submit" value="Sửa" /> 
                            <input class="submit-gray" type="reset" value="Hủy" />
                            @*<input class="submit-gray" type="button"  onclick="location.href='@Url.Action("Index", "User")'" value="Quay lại" />*@
                        </p>
                    </div>  
                }
                </div> <!-- End .module-body -->
        </div>  <!-- End .module -->
        <div style="clear:both;"></div>
    </div> <!-- End .grid_12 --> 
    <div style="clear:both;"></div>
</div> <!-- End .container_12 -->

<script type="text/javascript">
    $(document).ready(function () {
        $("#date").datepicker({ dateFormat: 'dd/mm/yy' });
    });
</script>
<script type="text/javascript">
    $("#main_stations_id").change(function () {
        $.ajax({
            type: "POST",
            url: '@Url.Action("getStationsJson", "Generator")',
            data: { MainStationId: $("#main_stations_id > option:selected").attr("value"), Order: "name" },
            success: function (data) {
                var items = [];
                items.push("<option>---Chọn nhà trạm---</option>");
                $.each(data, function () {
                    items.push("<option value=" + this.Value + ">" + this.Text + "</option>");
                });
                $("#stations_id").html(items.join(' '));
            }
        })
    });
</script>
